function getXmlHttpObject() {
	var xmlhttp;
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function preSearch() {
	/*http = getXmlHttpObject();
	term = document.getElementById('searchbox').value;
	http.open("GET", "index.php?q=" + term);
	http.onreadystatechange = new function() {
		if (http.readyState == 4) {
			alert(http.responseText);
		}
	}*/
}

function doSearch() {
	http = getXmlHttpObject();
	term = document.getElementById('searchbox').value;
	if (tag == "undefined") {
		t = "";
	} else {
		t = "&t=" + tag;
	}
	http.open("GET", "index.php?q=" + escape(term) + "&short=true" + t, true);
	http.onreadystatechange = function() {
		if (http.readyState == 1) {
			document.getElementById('results').innerHTML = '<div style="text-align:center;width:100%;"><img src="loadanim.gif" />';
		}
		
		if (http.readyState == 4) {
			document.getElementById('results').innerHTML = http.responseText;
		}
	}
	http.send(null);
}